<template>
   <PanelSplitTwo bottomToolbarHeight="0" :num="2" :sizes="1">
    <template #top>
      <SetUserSelect
        v-show="false"
        class="queryForm"
        :formData="orderSelect"
        :queryParams="paginationParams"
        @selectFunc="selectFunc"
      ></SetUserSelect>
    </template>
     <template #centerToolbar>
        <div class="vex_flex">
        <VxeTableGrid
          style="flex: 1;"
          :tableColumn="tableColumn"
          :tableLoading="tableLoading"
          :dataList="dataList"
          :showPagination="true"
          :paginationParams="paginationParams"
          @getList="setQueryParams"
          @selectedChange="selectedChange"
        >
        </VxeTableGrid>
      </div>
      
     </template>
   </PanelSplitTwo>
</template>

<script setup>
import { useRouter, useRoute } from 'vue-router'
import { listItem as initData } from "@/api/integral";
import datas from './data.js'
const { tableColumn, paginationParams, orderSelect }  = datas

const { proxy } = getCurrentInstance();
const router= useRouter ()
// paginationParams.value.id = useRoute().query.id
paginationParams.value.type = useRoute().query.type
paginationParams.value.id = useRoute().query.id
const onlineList = ref([]);
const loading = ref(false);
const total = ref(0);
const pageNum = ref(1);
const pageSize = ref(10);
let tableLoading = ref(false)
const dataList = ref([
])
tableColumn.value[3].slots = {
  default: ({ row }) => {
    return row.integralType == 0? '增加' : '减少'
  }
}
tableColumn.value[1].slots = {
  default: ({ row }) => {
    let text = ''
    if (row.mrId) {
      orderSelect[1].selectData.length > 0 && orderSelect[1].selectData.forEach((val) => {
        if (val.id == row.mrId) {
          text = val.name
        }
      })
    } else {
      orderSelect[0].selectData.length > 0 && orderSelect[0].selectData.forEach((val) => {
        if (val.id == row.agencyId) {
          text = val.name
        }
      })
    }
    return text
    // return row.type == 0? '代表' : '代理商'
  }
}
const queryParams = ref({
  ipaddr: undefined,
  userName: undefined
});
// 切换分页
  function setQueryParams(val) {
    paginationParams.value.pageNum = val.pageNum;
    paginationParams.value.pageSize = val.pageSize;
    getList()
  }
  // 选择表格
  function selectedChange(val) {
    console.log(val)
    // this.form.customerId = val.currentItem.customerId;
  }
/** 查询登录日志列表 */
tableLoading.value = true
function getList() {
  loading.value = true;
  initData(paginationParams.value).then(response => {
    dataList.value = response.rows;
    total.value = response.total;
    loading.value = false;
    tableLoading.value = false
    paginationParams.value.total = response.total;
  });
}
/** 搜索按钮操作 */
function handleQuery() {
  pageNum.value = 1;
  router.push({
    path: '/missionPlan/chekMissionPlan'
  })
}
/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm("queryRef");
  handleQuery();
}
/** 强退按钮操作 */
function handleForceLogout(row) {
    proxy.$modal.confirm('是否确认强退名称为"' + row.userName + '"的用户?').then(function () {
  return forceLogout(row.tokenId);
  }).then(() => {
    getList();
    proxy.$modal.msgSuccess("删除成功");
  }).catch(() => {});
}
setTimeout(() => {
  getList();
}, 500)
const selectFunc = () => {
  paginationParams.value.pageNum = 1
  getList()
}
</script>
<style scoped>
  .app-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 85px);
    overflow: hidden;
  }
  .vex_flex {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
    padding-top: 20px;
    box-sizing: border-box;
  }
  .flexmin {
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
</style>